<style>

</style>
<template>


<!-- 采购清单 -->
    <div>

              <Spin size="large" fix v-if="spinShow"></Spin>
       
    <!-- 根据条件查询 -->
    <div>
      <el-form :inline="true"  class="demo-form-inline" ref="ruleForm">
       
        <el-form-item label="单据编号">
          <el-input v-model="documentNumber" placeholder="请输入单据编号查询"></el-input>
        </el-form-item>
        <el-form-item label="商品信息">
          <el-input v-model="productName" placeholder="请输入商品信息查询"></el-input>
        </el-form-item>
        <el-form-item label=" 单据日期 ">
          <el-date-picker
            v-model="begintime"
            type="datetimerange"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            :default-time="['12:00:00']"
          ></el-date-picker>
        </el-form-item>
       
        <el-form-item>
          <el-button type="primary" plain   @click="findByPage">查询</el-button>
          <el-button @click="resetForm">重置</el-button>
        </el-form-item>
      </el-form>
    </div>


     <div style="margin-top: 20px;">
        <!-- <el-button type="primary" @click="addSalesOrder1" ><Icon type="md-add" /> 添加</el-button> -->
        <el-button type="primary" plain  @click="preAddPrecommodity" ><Icon type="md-add" /> 添加</el-button>

        <el-dropdown split-button type="primary" style="padding-left:20px" v-show="this.xlk">
          批量操作
          <el-dropdown-menu slot="dropdown">

            <el-dropdown-item>
            <i class="el-icon-delete"></i>
               <span  @click="delQD">删除</span>
            </el-dropdown-item>

              <el-dropdown-item>
              <Icon type="ivu-icon ivu-icon-ios-checkmark-circle-outline"/>
              <span @click="shenhe">审核</span>
            </el-dropdown-item>

              <el-dropdown-item>
            <Icon type="ios-add" />
               <span @click="preadd2Content">继续添加</span>
            </el-dropdown-item>
             
          </el-dropdown-menu>
        </el-dropdown>
      </div><br>



        <!-- table展示 -->
       <div>
         <Table
        border
        :columns="columns4"
        :data="data1"
         ref="selection"
           @on-selection-change="select2"
      >


      
         <template  slot-scope="scope" slot="types">
          <span >{{scope.row.erpSettlementaccount.accountName}}</span>
        </template>

          <template slot-scope="scope" slot="status">
          <el-tag :type="scope.row.sname==='审核'? 'primary':'danger'" >
            {{scope.row.sname=='审核'?"审核":"未审核"}}
            </el-tag>
        </template>
        

        

        
           <template slot-scope="{ row, index }" slot="action">
           <el-button type="primary" plain   @click="findErpPrecommodityDCNum(row)">查看</el-button>
        </template>

       
      </Table>
    </div>
    <br>



     <!-- 分页 -->
    <div style="float:right">
      <Page
        :total="dataCount"
        :page-size="pageSize"
        @on-change="changepage"
        @on-page-size-change="_nowPageSize"
        show-elevator
      />
    </div>

    <!-- addPrecommodity -->

<Modal v-model="addPrecommodity" title="新增订单"  width="1355" @on-ok="ok">



           <el-form :inline="true" :model="ErpPurchaselist" class="demo-form-inline">



            <el-form-item label="单据编号:">
              <el-input v-model="this.documentNumber2"  disabled=""></el-input>
            </el-form-item>   


            

           
             <el-form-item label="单据日期:">
              <div class="block">
                <el-date-picker v-model="this.addForm.createDate" type="datetime" placeholder="选择日期时间"  
                format="yyyy 年 MM 月 dd 日  HH时 mm分  ss秒"
                value-format="yyyy-MM-dd HH:mm:ss"
                ></el-date-picker>
              </div>
            </el-form-item>

            

             <el-form-item label="银行卡号:">
              <el-select  placeholder="请选择银行卡号:"  v-model="ErpPurchaselist.types" @change="selectType">
              <el-option v-for="item in ErpSettlementaccount" :label="item.accountNumber" :value="item.id"  ></el-option>
              </el-select>
            </el-form-item>

             <el-form-item label="开户银行::">
              <el-input v-model="this.SettlementaccountNum"  disabled=""></el-input>
            </el-form-item> 
          </el-form>

<br>
  
          <!-- 添加销售订单具体内容 -->
          <el-form ref="ErpSalescontent" :model="ErpPrecommodity" label-width="100px">
            <div style="border-left: 4px solid #39a9ff;padding-left: 8px;line-height: initial;font-size: initial;">
              <h4>采购清单</h4>
            </div>
            <br><br>
              <el-row :gutter="20">
                <el-col :span="7">
                  <el-form-item label="商品名称:" disabled="">
              
                           <el-select v-model="ErpPrecommodity.productName"  placeholder="请选择商品"  @change="selectGet2">
                        <el-option v-for="item in CommodityList" :label="(item.productName)+'  数量:'+(item.num) " :value="item.productName" ></el-option>
                    </el-select>
                  </el-form-item>
                </el-col>

                    
                <el-col :span="7">
                  <el-form-item label="采购价格:" >
                    <el-input v-model="ErpPrecommodity.purchasePrice" disabled="" ></el-input>
                  </el-form-item>
                </el-col>

             

                 <el-col :span="7">
                  <el-form-item label="商品单位:" >
     
                     <el-select v-model="ErpPrecommodity.unit" placeholder="请选择单位类型" disabled="">
                    <el-option :label="ErpPrecommodity.unitName" :value="ErpPrecommodity.unit"  ></el-option>  
                    </el-select>
                  </el-form-item>
                </el-col>
              </el-row>

              <!-- 第二行 -->
              <el-row :gutter="20">
                <el-col :span="7">
                  <el-form-item label="商品型号:" >
                    <el-input v-model="ErpPrecommodity.model" disabled="" ></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="7">
                  <el-form-item label="商品规格:" disabled="" >
                    <el-input v-model="ErpPrecommodity.specification" disabled="" ></el-input>
                  </el-form-item>
                </el-col>
          

                    <el-col :span="7">
                  <el-form-item label="商品类型:" >
                    <el-select v-model="ErpPrecommodity.type" placeholder="请选择商品类型" @change="selectGet">
                      <el-option v-for="item in styleComm" :label="item.classificationName" :value="item.id" ></el-option>                    </el-select>
                  </el-form-item>
                </el-col>



              </el-row>
              <el-row :gutter="20">
                <el-col :span="7">
                  <el-form-item label="商品数量:" >
                      <el-input v-model="ErpPrecommodity.num"></el-input>
                  </el-form-item>
                </el-col>
             
                <el-col :span="7">
                  <el-form-item label="扩展信息" >
                    <el-input v-model="ErpPrecommodity.extendedInformation" disabled="" ></el-input>
                  </el-form-item>
                </el-col>

                   <el-col :span="7">
                  <el-form-item label="仓库名称:" >
                     <el-select v-model="ErpPrecommodity.wid" placeholder="请选择仓库类型"  disabled="">
                    <el-option :label="ErpPrecommodity.rName" :value="ErpPrecommodity.wid" ></el-option>   
                    </el-select>
                  </el-form-item>

                </el-col>
              </el-row>
          </el-form>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             
      </Modal>




      <!-- 0000000000000000000000000000000000继续添加 -->
      <Modal v-model="addPrecommodity2" title="新增订单"  width="1355" @on-ok="ok2">



           <el-form :inline="true" :model="ErpPurchaselist" class="demo-form-inline">



            <el-form-item label="单据编号:">
              <el-input v-model="this.add2.documentNumber"  disabled=""></el-input>
            </el-form-item>   


            

           
             <el-form-item label="单据日期:">
              <div class="block">
                <el-date-picker v-model="this.add2.documentDate" type="datetime" placeholder="选择日期时间"  
                format="yyyy 年 MM 月 dd 日  HH时 mm分  ss秒"
                value-format="yyyy-MM-dd HH:mm:ss"
                disabled=""
                ></el-date-picker>
              </div>
            </el-form-item>
           </el-form>

            


<br>
  
          <!-- 添加销售订单具体内容 -->
          <el-form ref="ErpSalescontent" :model="ErpPrecommodity" label-width="100px">
            <div style="border-left: 4px solid #39a9ff;padding-left: 8px;line-height: initial;font-size: initial;">
              <h4>销售订单具体内容</h4>
            </div>
            <br><br>
              <el-row :gutter="20">
                <el-col :span="7">
                  <el-form-item label="商品名称:" disabled="">
              
                           <el-select v-model="ErpPrecommodity.productName"  placeholder="请选择商品"  @change="selectGet2">
                        <el-option v-for="item in CommodityList" :label="(item.productName)+'  数量:'+(item.num) " :value="item.productName" ></el-option>
                    </el-select>
                  </el-form-item>
                </el-col>

                    
                <el-col :span="7">
                  <el-form-item label="采购价格:" >
                    <el-input v-model="ErpPrecommodity.purchasePrice" disabled="" ></el-input>
                  </el-form-item>
                </el-col>

             

                 <el-col :span="7">
                  <el-form-item label="商品单位:" >
     
                     <el-select v-model="ErpPrecommodity.unit" placeholder="请选择单位类型" disabled="">
                    <el-option :label="ErpPrecommodity.unitName" :value="ErpPrecommodity.unit"  ></el-option>  
                    </el-select>
                  </el-form-item>
                </el-col>
              </el-row>

              <!-- 第二行 -->
              <el-row :gutter="20">
                <el-col :span="7">
                  <el-form-item label="商品型号:" >
                    <el-input v-model="ErpPrecommodity.model" disabled="" ></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="7">
                  <el-form-item label="商品规格:" disabled="" >
                    <el-input v-model="ErpPrecommodity.specification" disabled="" ></el-input>
                  </el-form-item>
                </el-col>
          

                    <el-col :span="7">
                  <el-form-item label="商品类型:" >
                    <el-select v-model="ErpPrecommodity.type" placeholder="请选择商品类型" @change="selectGet">
                      <el-option v-for="item in styleComm" :label="item.classificationName" :value="item.id" ></el-option>                    </el-select>
                  </el-form-item>
                </el-col>



              </el-row>
              <el-row :gutter="20">
                <el-col :span="7">
                  <el-form-item label="商品数量:" >
                      <el-input v-model="ErpPrecommodity.num"></el-input>
                  </el-form-item>
                </el-col>
             
                <el-col :span="7">
                  <el-form-item label="扩展信息" >
                    <el-input v-model="ErpPrecommodity.extendedInformation" disabled="" ></el-input>
                  </el-form-item>
                </el-col>

                   <el-col :span="7">
                  <el-form-item label="仓库名称:" >
                     <el-select v-model="ErpPrecommodity.wid" placeholder="请选择仓库类型"  disabled="">
                    <el-option :label="ErpPrecommodity.rName" :value="ErpPrecommodity.wid" ></el-option>   
                    </el-select>
                  </el-form-item>

                </el-col>
              </el-row>
          </el-form>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             
      </Modal>








          <!-- 根据订单编号查看 -->
    <Modal v-model="findSalseDMNumContent" title="查看" width="1340">
      <Table border ref="selection" :columns="columns5" :data="DMNumList" height="350" >

         <template slot-scope="{ row, index }" slot="upd">
            <el-button type="primary" icon="el-icon-edit" circle   @click="preupd(row)"></el-button>
         </template>

          <template slot-scope="{ row, index }" slot="del">
             <el-button type="danger" icon="el-icon-delete" circle  @click="predel(row)"></el-button>
         </template>
      </Table>
    </Modal>
    

 <Modal
        v-model="delM"
        title="警告"
        
        @on-ok="del">
        <p>确定要删除吗?</p>
    </Modal>


     <Modal
        v-model="updModel"
        title="警告"
           width="1000"
        @on-ok="upd2"
      >
      <!-- 添加销售订单具体内容 -->
       <el-form  :model="PreContent" class="demo-form-inline" >
           
            <br><br>
              <el-row :gutter="20">
                <el-col :span="7">
                <el-form-item label="商品名称:" >
                    <el-input v-model="PreContent.productName" disabled="" ></el-input>
                  </el-form-item>
                </el-col>

                    
                <el-col :span="7">
                  <el-form-item label="采购价格:" >
                    <el-input v-model="PreContent.purchasePrice" disabled="" ></el-input>
                  </el-form-item>
                </el-col>

             

                 <el-col :span="7">
                  <el-form-item label="商品单位:" >
                    <el-input v-model="PreContent.units" disabled=""></el-input>
                  </el-form-item>
                </el-col>
              </el-row>

              <!-- 第二行 -->
              <el-row :gutter="20">
                <el-col :span="7">
                  <el-form-item label="商品型号:" >
                    <el-input v-model="PreContent.model" disabled="" ></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="7">
                  <el-form-item label="商品规格:" disabled="" >
                    <el-input v-model="PreContent.specification" disabled="" ></el-input>
                  </el-form-item>
                </el-col>
          

                    <el-col :span="7">
                  <el-form-item label="商品类型:" >
                       <el-input v-model="PreContent.typeName" disabled=""></el-input>
                  </el-form-item>
                </el-col>



              </el-row>
              <el-row :gutter="20">
                <el-col :span="7">
                  <el-form-item label="商品数量:" >
                      <el-input v-model="PreContent.num"></el-input>
                  </el-form-item>
                </el-col>
             
                <el-col :span="7">
                  <el-form-item label="扩展信息" >
                    <el-input v-model="PreContent.extendedInformation" disabled="" ></el-input>
                  </el-form-item>
                </el-col>

                   <el-col :span="7">
                  <el-form-item label="仓库名称:" >
                           <el-input v-model="PreContent.rname" disabled="" ></el-input>
                  </el-form-item>

                </el-col>
              </el-row>
          </el-form>
    </Modal>



    </div>
</template>
<script>
import axios from "axios";
export default {
   data() {
      return {

        addPrecommodity2:false,

          //银行名称
        SettlementaccountNum:"",

        ErpPurchaselist:{},

           //默认时间
    addForm:{
        createDate:new Date()
      },

      documentNumber2:"",


          findSalseDMNumContent:false,

          //银行卡
          ErpSettlementaccount:[],

          //类型
          styleComm:[],

          //仓库
          RList:[],

          //单位
          UnitList:[],

          addPrecommodity:false,

          ErpPrecommodity:{},


          findSalseDMNumContent:false,

             columns5: [
          
        {
          title: "#",
          key: "id",
            align:"center",
        },
     
        {
          title: "商品名称",
          key: "productName",
            align:"center",
        },
           {
          title: "单据编号",
          key: "documentNumber",
            align:"center",
        },

            {
            title:"采购价格",
            key:"purchasePrice",
            align:"center",
        },
       
        
     
        {
          title: "数量",
          key: "num",
            align:"center",
        },

        
          {
          title: "商品单位",
          key: "units",
            align:"center",
        },
          {
          title: "商品型号",
          key: "model",
            align:"center",
        },
         {
          title: "商品规格",
          key: "specification",
            align:"center",
        },
         {
            title:"仓库名称",
            key:"rname",
            align:"center",
        },
          {
          title: "商品类型",
          key: "typeName",
            align:"center",
        },
          {
          title: "修改",
          slot: "upd",
            align:"center",
        },
          {
          title: "删除",
          slot: "del",
            align:"center",
        }

        
        
      ],

  



           columns4: [
                {
          type: "selection",
          width: 60,
          align: "center"
        },
        {
          title: "#",
          key: "id",
            align:"center",
        },
     
        {
          title: "商品名称",
          key: "productName",
            align:"center",
        },
           {
          title: "单据编号",
          key: "documentNumber",
            align:"center",
        },

            {
            title:"单据日期",
            key:"documentDate",
            align:"center",
        },
       
        
     
        {
          title: "总金额",
          key: "totalAmount",
            align:"center",
        },
        {
         title: "支付类型",
          key: "bank",
            align:"center"},

         {
            title:"状态",
            slot:"status",
            align:"center",
        },
          {
          title: "operate",
          slot: "action",
            align:"center",
        }
        
      ],
      data1: [],

      xlk:false,

        spinShow:true,
        DMNumList:[],


                   // 分页的条件
      productName: "",
      documentNumber: "",
      begintime: [],


      //分页
        pageSize: 5, //每页显示多少条
      dataCount: 0, //总条数
      pageCurrent: 1, //当前页,


      //存放多选框的值
      tableSelection:[],

      //根据商品类型查询商品表
      CommodityList:[],


      add2:{},
      delId:"",
      delM:false,

      PreContent:{},
      updModel:false
      }
      
   },
   created(){
       this.getList();
       this.getCommodityStyleList2();
       this.getWarehouseinformation();
       this.getUnitList();
       this.getErpSettlementaccount();
   },

   methods:{


     upd2(){
       this.spinShow=true;
        axios.post("//localhost:8082/Purchaselist/upd",this.PreContent).then(res=>{
          
   if(res.data==1){
         this.$notify({
          title: '成功',
          message: '恭喜你,修改成功',
          type: 'success'
        });
         }else{
            this.$notify({
          title: '警告',
          message: '数量超出范围!',
          type: 'warning'
        });
         }
         this.spinShow=false;
         this.getList();
        })
     },

     preupd(row){
        this.updModel=true;
        this.PreContent=row;
        this.findSalseDMNumContent=false;
        console.log(this.PreContent)
     },



     del(){
       this.spinShow=true;
     axios.post("//localhost:8082/Purchaselist/del?id="+this.delId).then(res=>{
         if(res.data==1){
         this.$notify({
          title: '成功',
          message: '恭喜你,删除成功',
          type: 'success'
        });
         }else{
            this.$notify({
          title: '警告',
          message: '删除成功',
          type: 'warning'
        });
         }

         this.spinShow=false;
         this.getList();


       })

     },
     


     //删除
     predel(row){
       this.delId=row.id;
       this.delM=true;
       this.findSalseDMNumContent=false;
  


     },

     upd(row){

     },


//继续添加  预添加
     preadd2Content(){
        if(this.tableSelection.length==1){
 this.add2=this.tableSelection[0]
    console.log(this.add2)
    this.addPrecommodity2=true;
        }else{
           this.$notify({
          title: '警告',
          message: '请选择一条进行操作',
          type: 'warning'
        });
        }


       

     },

     ok2(){
         axios.post("//localhost:8082/Purchaselist/add2PreList?documentNumber="+this.add2.documentNumber,this.ErpPrecommodity).then(res=>{
        if(res.data=="1"){
                //刷新
        this.getList();
         this.$notify({
          title: '成功',
          message: '恭喜你,再次添加成功',
          type: 'success'
        });
          } else{
             this.$notify({
          title: '警告',
          message: '商品数量不足或商品低于最低采购价格无法添加!',
          type: 'warning'
        });
          }
          this.getList();
         
        })
       
     },






     //点击下拉框的值  触发事件  将一条数据赋值给各个input
selectGet2(name){

      let obj = {};
      //循环判断
      obj=this.CommodityList.find((item)=>{
          return item.productName===name
      })
      
       this.ErpPrecommodity.purchasePrice=obj.purchasePrice
//  this.ErpPrecommodity.unit=obj.erpUnit.id
  this.ErpPrecommodity.unitName=obj.unitList.basicUnit
 this.ErpPrecommodity.model=obj.model
 this.ErpPrecommodity.specification=obj.specification
//  this.ErpPrecommodity.num=obj.num
//  this.ErpPrecommodity.extendedInformation=obj.extendedInformation
 this.ErpPrecommodity.wid=obj.erpWarehouseinformation.id
 this.ErpPrecommodity.rName=obj.erpWarehouseinformation.resName
 this.ErpPrecommodity.barcode=obj.barcode




     
      
},


     //点击下拉框  商品类型的值  触发事件  获取已经入库的list
selectGet(vId){
      let obj = {};
      obj=this.styleComm.find((item)=>{
          return item.id===vId
      })
      console.log(obj.id)
      axios.post("//localhost:8082/commodity/getCommListByType?type="+obj.id).then(
        res=>{
            this.CommodityList=res.data;
            console.log(this.CommodityList)
        }
      )
},


     
//支付类型下拉框选中事件
    selectType(value){
        console.log(value)
        for(var i=0;i<this.ErpSettlementaccount.length;i++){
          if(value==this.ErpSettlementaccount[i].id){
              this.SettlementaccountNum=this.ErpSettlementaccount[i].accountName
          }
        }
        console.log(this.SettlementaccountNum)
    },

     getErpSettlementaccount(){
        axios.get("http://localhost:8082/Settlementaccount/getSettList").then(res=>{
          this.ErpSettlementaccount=res.data;
          console.log(this.ErpSettlementaccount)
        })
     },

// 删除清单
     delQD(){
       //创建一个数组
      let ids = [];
      //赋值
      this.tableSelection.forEach(function(e) {
        ids.push(e.id);
      });
  this.$confirm('确定启用吗?, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          //当点击确定  开始加载特效
           this.spinShow=true;
           //跨域
            axios.post("http://localhost:8082/Purchaselist/delQK",ids)
            .then(res => {
              if(res.data==1){
          //成功的提示
                        this.$notify({
                    title: '删除成功',
                    message: '恭喜你删除成功',
                    type: 'success'
                  });
              }else{
            
          this.$notify({
          title: '警告',
          message: '删除之前请先查看并审核',
          type: 'warning'
        });
              }
             
        //刷新
            this.getList();   
            //当启用成功以后  结束加载特效
             this.spinShow=false;     
            });

  this.getSalesOrderList();
        }).catch(() => {
               
        });






     },

     shenhe(){
      if(this.tableSelection.length==1){
    //创建一个数组
      let ids = [];
      //赋值
      this.tableSelection.forEach(function(e) {
        ids.push(e.id);
      });
    
       this.$confirm('确定启用吗?, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          //当点击确定  开始加载特效
           this.spinShow=true;
           //跨域
            axios.post("http://localhost:8082/Purchaselist/shenhe?id="+ ids[0])
            .then(res => {
              if(res.data==1){
          //成功的提示
                        this.$notify({
                    title: '审核成功',
                    message: '恭喜你审核成功',
                    type: 'success'
                  });
              }else{
            
          this.$notify({
          title: '警告',
          message: '审核之前请认真查看该订单的商品!',
          type: 'warning'
        });
              }
             
        //刷新
            this.getList();   
            //当启用成功以后  结束加载特效
             this.spinShow=false;     
            });

  this.getSalesOrderList();
        }).catch(() => {
              
        });
        }else{
           this.$notify.info({
          title: '消息',
          message: '请选择一条内容进行添加'
        });
        }
     },














    //  根据单据编号查询
    findErpPrecommodityDCNum(row){
      console.log(row)
      axios
        .get(
          "http://localhost:8082/ErpPrecommodity/findErpPrecommodityDCNum?documentNumber=" +
            row.documentNumber
        )
        .then(res => {
          
          this.DMNumList = res.data;
          console.log(this.DMNumList)
          this.findSalseDMNumContent = true;
        });
    },


       //查找单位List
       getUnitList(){
        axios
        .post(
          "//localhost:8082/Unit/getUnitList"
        )
        .then(res => {
          console.log(res.data)
          this.UnitList=res.data;
          console.log(this.UnitList)
        });
    },


           //查找商品类型List
       getCommodityStyleList2(){
        axios
        .post(
          "//localhost:8082/ErpCommoditystyle/getCommodityStyleList"
        )
        .then(res => {
          console.log(res.data)
          this.styleComm=res.data;
          console.log(this.styleComm)
        });
    },


           //查找仓库List
       getWarehouseinformation(){
        axios
        .post(
          "//localhost:8082/Warehouseinformation/w"
        )
        .then(res => {
          console.log(res.data)
          this.RList=res.data;
          console.log(this.RList)
        });
    },





// 添加
       ok(){
          this.ErpPurchaselist.documentNumber=this.documentNumber2;
      this.ErpPurchaselist.documentDate=this.addForm.createDate;

//时间转换
 var d=this.addForm.createDate;
      
var datetime=d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate() + ' ' + d.getHours() + ':' + d.getMinutes() + ':' + d.getSeconds();

    //   console.log(this.ErpPurchaselist.documentNumber)
    // console.log(datetime)    
    // console.log(this.ErpPurchaselist.types)   
    //  console.log(this.ErpPrecommodity)


     axios.post("//localhost:8082/Purchaselist/addPueList?documentDate="+datetime
        +"&documentNumber="+this.ErpPurchaselist.documentNumber+"&types="+this.ErpPurchaselist.types
       , this.ErpPrecommodity).then(res=>{
          console.log("123")
          console.log(res.data)
          if(res.data=="1"){
                //刷新
        this.getList();
         this.$notify({
          title: '成功',
          message: '恭喜你,添加成功666',
          type: 'success'
        });
          }
        else{
             this.$notify({
          title: '警告',
          message: '添加失败,数据可能为空',
          type: 'warning'
        });
          }
        
      })




       },


         // 添加采购清单的内容  第一条
    preAddPrecommodity(){
        //当点击一次添加   自动更新一次订单编号
      this.documentNumber2='AZ'+this.getProjectNum()+Math.floor(Math.random() * 10000) ;
      this.addPrecommodity=true;
      this.ErpPurchaselist={},
      this.ErpPrecommodity={}
    },




        
    // 当选中的时候触发   没有选中不触发
    select2(rows) {
      this.tableSelection = rows;
      console.log(this.tableSelection);
      this.xlk = true;
      if (this.tableSelection.length == 0) {
        this.xlk = false;
      }
    },









       
    getList(){
       axios
        .post(
              "//localhost:8082/Purchaselist/getPurchaselistPage1?documentNumber=" +
            this.documentNumber +
            "&productName=" +
            this.productName +
            "&time=" +
            this.begintime +
            "&pageSize=" +
            this.pageSize +
            "&pageCurrent=" +
            this.pageCurrent
        )
        .then(res => {
          console.log("13123123123213")
          console.log(res.data);
          this.dataCount = res.data.countTotal;
          this.data1 = res.data.list;
         
          //当从数据库获取完毕  关闭加载特效
          this.spinShow=false;
          // this.begintime = "";
        });
    },
 


       //条件查询
    findByPage(){
         this.spinShow=true;
       axios
        .post(
          "//localhost:8082/Purchaselist/getPurchaselistPage1?documentNumber=" +
            this.documentNumber +
            "&productName=" +
            this.productName +
            "&time=" +
            this.begintime +
            "&pageSize=" +
            this.pageSize +
            "&pageCurrent=" +
            this.pageCurrent
        )
        .then(res => {
          console.log("13123123123213")
          console.log(res.data);
          this.dataCount = res.data.countTotal;
          this.data1 = res.data.list;
         
          //当从数据库获取完毕  关闭加载特效
          this.spinShow=false;
          // this.begintime = "";
        });
    },
            //点击这个,即可换页数


    changepage(index) {
         this.spinShow=true;
       axios
        .post(
          "//localhost:8082/Purchaselist/getPurchaselistPage1?documentNumber=" +
            this.documentNumber +
            "&productName=" +
            this.productName +
            "&time=" +
            this.begintime +
            "&pageSize=" +
            this.pageSize +
            "&pageCurrent=" +
            index
        )
        .then(res => {
          console.log("13123123123213")
          console.log(res.data);
          this.dataCount = res.data.countTotal;
          this.data1 = res.data.list;
         
          //当从数据库获取完毕  关闭加载特效
          this.spinShow=false;
          // this.begintime = "";
        });
    },

    //每页显示的数据条数
    _nowPageSize(index) {
      //实时获取当前需要显示的条数
      this.pageSize = index;
    },



             // 重置
    resetForm() {
      this.documentNumber = "";
      this.begintime = [];
      this.productName = "";
    },
     //生成单据编号
    // 获取当前日期的方法
	    getProjectNum () {
      const projectTime = new Date() // 当前中国标准时间
      const Year = projectTime.getFullYear() // 获取当前年份 支持IE和火狐浏览器.
      const Month = projectTime.getMonth() + 1 // 获取中国区月份
      const Day = projectTime.getDate() // 获取几号
      var CurrentDate = Year
      if (Month >= 10) { // 判断月份和几号是否大于10或者小于10
        CurrentDate += Month
      } else {
        CurrentDate += '0' + Month
      }
      if (Day >= 10) {
        CurrentDate += Day
      } else {
        CurrentDate += '0' + Day
      }
      return CurrentDate+1
},

   }
   
}
</script>
